package com.chang.dp.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chang.dp.entity.BookSectionEntity;
import com.chang.dp.mappers.BookSectionMapper;
import com.chang.dp.services.BookSectionService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookSectionServiceImpl extends ServiceImpl<BookSectionMapper, BookSectionEntity> implements BookSectionService {

    @Override
    public List<BookSectionEntity> listByBookId(Long bookId) {
        QueryWrapper<BookSectionEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper
                .lambda()
                .eq(BookSectionEntity::getBookId, bookId)
                .select(
                        BookSectionEntity::getId,
                        BookSectionEntity::getBookId,
                        BookSectionEntity::getTitle,
                        BookSectionEntity::getPageNumber,
                        BookSectionEntity::getSubject
                );

        // 明确指定需要查询的字段，排除 subject 字段

        List<BookSectionEntity> bookSectionEntities = this.getBaseMapper().selectList(queryWrapper);
        return bookSectionEntities;
    }
}
